import java.net.InetAddress;

/**
 * @Author ufo
 * @Description TODO
 * @Date 2021/1/18 11:47
 * @Version 1.0
 */
public class InetAddressTest {

        public static void main(String[] args) throws Exception {
            java.net.InetAddress local = java.net.InetAddress.getLocalHost();
            java.net.InetAddress remote = java.net.InetAddress.getByName("www.baidu.com");
            System.out.println("本机的IP地址：" + local.getHostAddress());
            System.out.println("baidu的IP地址：" + remote.getHostAddress());
            System.out.println("baidu的主机名为：" + remote.getHostName());
    }





}
